home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / gedit-2 / plugins / snippets / c.xml next >
Encoding:
Extensible Markup Language  |  2009-04-14  |  7.2 KB  |  284 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <snippets language="C">
  3.   <snippet id="gpl">
  4.     <text><![CDATA[/*
  5.  * ${1:[$GEDIT_BASENAME,<filename>]}
  6.  * This file is part of ${2:<program name>}
  7.  *
  8.  * Copyright (C) $<3: import datetime; return str(datetime.date.today().year)> - $<4:
  9. import pwd, os
  10. try:
  11.   return pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0]
  12. except KeyError:
  13.   return '<author\>' >
  14.  *
  15.  * ${2} is free software; you can redistribute it and/or modify
  16.  * it under the terms of the GNU General Public License as published by
  17.  * the Free Software Foundation; either version 2 of the License, or
  18.  * (at your option) any later version.
  19.  *
  20.  * ${2} is distributed in the hope that it will be useful,
  21.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23.  * GNU General Public License for more details.
  24.  *
  25.  * You should have received a copy of the GNU General Public License
  26.  * along with ${2}; if not, write to the Free Software
  27.  * Foundation, Inc., 51 Franklin St, Fifth Floor, 
  28.  * Boston, MA  02110-1301  USA
  29.  */
  30.  
  31.  $0]]></text>
  32.     <tag>gpl</tag>
  33.     <description>GPL License</description>
  34.   </snippet>
  35.   <snippet id="lgpl">
  36.     <text><![CDATA[/*
  37.  * ${1:[$GEDIT_BASENAME,<filename>]}
  38.  * This file is part of ${2:<library name>} 
  39.  *
  40.  * Copyright (C) $<3: import datetime; return str(datetime.date.today().year)> - $<4:
  41. import pwd, os
  42. try:
  43.   return pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0]
  44. except KeyError:
  45.   return '<author\>' >
  46.  *
  47.  * ${2} is free software; you can redistribute it and/or
  48.  * modify it under the terms of the GNU Lesser General Public
  49.  * License as published by the Free Software Foundation; either
  50.  * version 2.1 of the License, or (at your option) any later version.
  51.  * 
  52.  * ${2} is distributed in the hope that it will be useful,
  53.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  54.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  55.  * Lesser General Public License for more details.
  56.  * 
  57.  * You should have received a copy of the GNU Lesser General Public
  58.  * License along with this library; if not, write to the Free Software
  59.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  60.  */
  61.  
  62.  $0]]></text>
  63.     <tag>lgpl</tag>
  64.     <description>LGPL License</description>
  65.   </snippet>
  66.   <snippet id="do">
  67.     <text><![CDATA[do
  68. {
  69.     $0
  70. } while ($1);]]></text>
  71.     <tag>do</tag>
  72.     <description>do .. while</description>
  73.   </snippet>
  74.   <snippet id="for">
  75.     <text><![CDATA[for (${1:i} = ${2:0}; ${1:i} < ${3:count}; ${1:i} += ${4:1})
  76. {
  77.     $0
  78. }]]></text>
  79.     <tag>for</tag>
  80.     <description>for loop</description>
  81.   </snippet>
  82.   <snippet id="while">
  83.     <text><![CDATA[while (${1:condition})
  84. {
  85.     $0
  86. }]]></text>
  87.     <tag>while</tag>
  88.     <description>while loop</description>
  89.   </snippet>
  90.   <snippet id="if">
  91.     <text><![CDATA[if (${1:condition})
  92. {
  93.     $0
  94. }]]></text>
  95.     <tag>if</tag>
  96.     <description>if</description>
  97.   </snippet>
  98.   <snippet id="elif">
  99.     <text><![CDATA[else if (${1:condition})
  100. {
  101.     $0
  102. }]]></text>
  103.     <tag>elif</tag>
  104.     <description>else if</description>
  105.   </snippet>
  106.   <snippet id="else">
  107.     <text><![CDATA[else
  108. {
  109.     $0
  110. }]]></text>
  111.     <tag>else</tag>
  112.     <description>else</description>
  113.   </snippet>
  114.   <snippet id="Inc">
  115.     <text><![CDATA[#include <${1:file}.h>
  116. $0]]></text>
  117.     <tag>Inc</tag>
  118.     <description>#include <..></description>
  119.   </snippet>
  120.   <snippet id="inc">
  121.     <text><![CDATA[#include "${1:file}.h"
  122. $0]]></text>
  123.     <tag>inc</tag>
  124.     <description>#include ".."</description>
  125.   </snippet>
  126.   <snippet id="main">
  127.     <text><![CDATA[int 
  128. main (int argc, char *argv[])
  129. {
  130.     $0
  131.     return 0;
  132. }]]></text>
  133.     <tag>main</tag>
  134.     <description>main</description>
  135.   </snippet>
  136.   <snippet id="struct">
  137.     <text><![CDATA[struct ${1:name}
  138. {
  139.     ${0:/* data */}
  140. };]]></text>
  141.     <tag>struct</tag>
  142.     <description>struct</description>
  143.   </snippet>
  144.   <snippet id="endif">
  145.     <text><![CDATA[#endif
  146. $0]]></text>
  147.     <description>#endif</description>
  148.     <accelerator><![CDATA[<Control><Alt>period]]></accelerator>
  149.   </snippet>
  150.   <snippet id="td">
  151.     <text><![CDATA[typedef ${1:newtype} ${2:type};
  152. $0]]></text>
  153.     <tag>td</tag>
  154.     <description>typedef</description>
  155.   </snippet>
  156.   <snippet id="gobject">>
  157.     <text><![CDATA[#include "$1.h"
  158. $<
  159. global camel_str,low_str, type_str, is_str, up_str
  160. components = $1.split('-')
  161. low_str = '_'.join(components).lower()
  162. up_str = '_'.join(components).upper()
  163. type_str = '_'.join([components[0], 'TYPE'] + components[1:]).upper()
  164. is_str = '_'.join([components[0], 'IS'] + components[1:]).upper()
  165. camel_str = ''
  166.  
  167. for t in components:
  168.   camel_str += t.capitalize()
  169. >
  170.  
  171. #define $<[1]: return up_str >_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), $<[1]: return type_str >, $<[1]: return camel_str >Private))
  172.  
  173. struct _$<[1]: return camel_str >Private
  174. {
  175. };
  176.  
  177. G_DEFINE_TYPE ($<[1]: return camel_str >, $<[1]: return low_str >, ${2:G_TYPE_OBJECT})
  178.  
  179. static void
  180. $<[1]: return low_str>_finalize (GObject *object)
  181. {
  182.     G_OBJECT_CLASS ($<[1]: return low_str >_parent_class)->finalize (object);
  183. }
  184.  
  185. static void
  186. $<[1]: return low_str >_class_init ($<[1]: return camel_str >Class *klass)
  187. {
  188.     GObjectClass *object_class = G_OBJECT_CLASS (klass);
  189.     
  190.     object_class->finalize = $<[1]: return low_str >_finalize;
  191.  
  192.     g_type_class_add_private (object_class, sizeof($<[1]: return camel_str >Private));
  193. }
  194.  
  195. static void
  196. $<[1]: return low_str >_init ($<[1]: return camel_str> *self)
  197. {
  198.     self->priv = $<[1]: return up_str >_GET_PRIVATE (self);
  199. }
  200.  
  201. $<[1]: return camel_str >*
  202. $<[1]: return low_str >_new ()
  203. {
  204.     return g_object_new ($<[1]: return type_str >, NULL);
  205. }]]></text>
  206.     <tag>gobject</tag>
  207.     <description>GObject template</description>
  208.   </snippet>
  209.   <snippet id="ginterface">
  210.     <text><![CDATA[#include "$1.h"
  211. $<
  212. global camel_str,low_str,up_str
  213. components = $1.split('-')
  214. low_str = '_'.join(components).lower()
  215. up_str = '_'.join(components).upper()
  216. camel_str = ''
  217.  
  218. for t in components:
  219.   camel_str += t.capitalize()
  220. >
  221. /*
  222.  * This is an method example for an interface
  223.  */
  224. const gchar *
  225. $<[1]: return low_str>_example_method ($<[1]: return camel_str > *self)
  226. {
  227.     g_return_val_if_fail ($<[1]: return up_str> (self), NULL);
  228.     return $<[1]: return up_str>_GET_INTERFACE (self)->example_method (self);
  229. }
  230.  
  231. /* Default implementation */
  232. static const gchar *
  233. $<[1]: return low_str>_example_method_default ($<[1]: return camel_str > *self)
  234. {
  235.     g_return_val_if_reached (NULL);
  236. }
  237.  
  238. static void 
  239. $<[1]: return low_str>_init ($<[1]: return camel_str >Iface *iface)
  240. {
  241.     static gboolean initialized = FALSE;
  242.     
  243.     iface->example_method = $<[1]: return low_str>_example_method_default;
  244.     
  245.     if (!initialized)
  246.     {
  247.         initialized = TRUE;
  248.     }
  249. }
  250.  
  251. GType 
  252. $<[1]: return low_str>_get_type ()
  253. {
  254.     static GType $<[1]: return low_str>_type_id = 0;
  255.     
  256.     if (!$<[1]: return low_str>_type_id)
  257.     {
  258.         static const GTypeInfo g_define_type_info =
  259.         {
  260.             sizeof ($<[1]: return camel_str >Iface),
  261.             (GBaseInitFunc) $<[1]: return low_str>_init, 
  262.             NULL,
  263.             NULL,
  264.             NULL,
  265.             NULL,
  266.             0,
  267.             0,
  268.             NULL
  269.         };
  270.         
  271.         $<[1]: return low_str>_type_id = 
  272.             g_type_register_static (G_TYPE_INTERFACE,
  273.                         "$<[1]: return camel_str>",
  274.                         &g_define_type_info,
  275.                         0);
  276.     }
  277.     
  278.     return $<[1]: return low_str>_type_id;
  279. }]]></text>
  280.     <tag>ginterface</tag>
  281.     <description>GObject interface</description>
  282.   </snippet>
  283. </snippets>
  284.